package com.lingyun.mqttserver.controller;

import com.lingyun.mqttserver.service.ManageDataService;
import com.lingyun.mqttserver.vo.LowerComputerVariableVo;
import com.lingyun.mqttserver.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("lower-computer")
public class LowerComputerVariableController {

    @Autowired
    private ManageDataService manageDataService;

    /**
     * 下位机变量列表
     * @param deviceId
     * @return
     */
    @GetMapping("variablesList")
    private Result variablesList(@RequestParam(required = false, defaultValue = "1") Integer page, @RequestParam(required = false, defaultValue = "10") Integer size, @RequestParam(required = false) Integer deviceId, @RequestParam(required = false) Integer projectId, @RequestParam(required = false) Integer deviceTypeId) {
        return manageDataService.variablesList(page, size, deviceId, projectId, deviceTypeId);
    }

    /**
     * 新增或更新设备变量
     */
    @PostMapping("variablesSave")
    public Result saveDeviceVariable(@RequestBody LowerComputerVariableVo vo) {
        return manageDataService.saveDeviceVariable(vo);
    }

    /**
     * 删除设备变量
     */
    @DeleteMapping("deleteDeviceVariable")
    public Result deleteDeviceVariable(@RequestParam Integer id) {
        return manageDataService.deleteDeviceVariable(id);
    }





}
